// custom-tab-bar/index.js
Component({
  data: {
    selected: 0,
    color: "#aaa",
    selectedColor: "#000",
    list: [
      {
        normal: '../static/tabbar/home.png',
        active: '../static/tabbar/home_active.png',
        text: '首页',
        url: '/pages/home/home'
      },
      // {
      //   normal: '../static/tabbar/chat.png',
      //   active: '../static/tabbar/chat_active.png',
      //   text: '问答',
      //   url: '/pages/question/question'
      // },
      {
        normal: '../static/tabbar/learn.png',
        active: '../static/tabbar/learn_active.png',
        text: '指南解读',
        url: '/pages/learning/learning'
      },
      {
        normal: '../static/tabbar/case.png',
        active: '../static/tabbar/case_active.png',
        text: '案例',
        url: '/pages/case/case'
      },
      {
        normal: '../static/tabbar/my.png',
        active: '../static/tabbar/my_active.png',
        text: '我的',
        url: '/pages/my/my'
      }
    ]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset
      const {path, index} = data
      wx.switchTab({
        url: path
      })
      //  这里设置无效，外部写入
      // this.setData({
      //   selected: index
      // })
    }
  }
})